#ifndef __DATABASE_STUFF_H
#define __DATABASE_STUFF_H

#include "mysqli.h"
#include "mysqli_bind.h"
//#include "Node.h"
#include "Tree.h"
#include "IPAddress.h"

class DatabaseStuff
{
	public:
	static void GetIPsToBan(Tree<IPAddress> &tree,const char *server); // Get the list of IPs to ban from the database.
	static void GetLastBannedTime(const char *server,char *output,unsigned long maxLength); // Returns the last time an IP was banned.
	private:
	static void OpenDatabase(mysqli &db,const char *server); // Opens a database connection.
	static void rot13(const char *original,char *output); // A simple cipher that's good enough to beat someone with a hex editor.
	static void PrepareGetNewBannedQuery(mysqli &db,mysqli_stmt &stmt); // Prepares the query to get new banned IPs.
	static void PrepareGetLastBannedTimeQuery(mysqli &db,mysqli_stmt &stmt); // prepares the query to get the last time something was banned.
	static bool IsServerAUrl(const char *server);
};

#endif
